package com.own.component.util.excel.util.read.base;

import com.own.component.util.excel.util.read.model.ResolveFileModel;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;

/**
 * BaseZipExcelReadConfig
 *
 * @author chenxueli
 * @date 2022-10-10 10:33:00
 */
public abstract class BaseZipExcelReadConfig<T> implements Serializable {

    /**
     * 设置文件的key
     */
    @Getter
    @Setter
    private BiConsumer<T, List<ResolveFileModel>> setFileKey;

    /**
     * 获取匹配的key
     */
    @Getter
    @Setter
    private BiFunction<T, ResolveFileModel, Boolean> patternKey;

    private Boolean flag;

    /**
     * 是否可以解析文件信息
     *
     * @return true:可以解析文件信息
     */
    public boolean canResolveFile() {
        if (flag == null) {
            this.flag = setFileKey != null && patternKey != null;
        }
        return flag;
    }

}
